
PM_FUNC_PUBLIC_ATTRIB ForwardGetGameDescription()
{
	forward_return( FMV_STRING, "PokeMod" );
	return FMRES_SUPERCEDE;
}

PM_FUNC_PUBLIC_ATTRIB ForwardAlertMessage()
	return FMRES_SUPERCEDE;

#define ForwardClientAuthorized client_authorized
PM_FUNC_PUBLIC_ATTRIB ForwardClientAuthorized( Int:iPlayer )
{
	pokemod_funcstart_debug( "ForwardClientAuthorized" );

	g_iLargestPlayer = max( g_iLargestPlayer, iPlayer );

	if ( PlayerGetInfo( iPlayer, PINFO_CONNECT ) )
	{
		pokemod_debug( "ForwardClientAuthorized called when already authorized (%s)", PlayerToName( iPlayer ) );
	}
	else
	{
		PlayerResetInfo( iPlayer );
		PlayerSetInfo( iPlayer, PINFO_CONNECT, 1 );

		if ( is_user_bot( iPlayer ) )
			PlayerSetInfo( iPlayer, PINFO_BOT, 1 );

		SetupArray( g_iPlayerItems[ iPlayer ], 1 ); 
		SetupTrie( g_iPlayerSpecials[ iPlayer ] );

		TradeClear( iPlayer );

		LoadPlayer( iPlayer );
	}

	pokemod_funcend_debug( "ForwardClientAuthorized" );
}

#define ForwardClientDisconnect client_disconnect
PM_FUNC_PUBLIC_ATTRIB ForwardClientDisconnect( Int:iPlayer )
{
	pokemod_funcstart_debug( "ForwardClientDisconnect" );

	PlayerSetInfo( iPlayer, PINFO_CONNECT, 0 );

	ArrayDestroy( g_iPlayerItems[ iPlayer ] ); 
	TrieDestroy( g_iPlayerSpecials[ iPlayer ] );

	if ( g_iLargestPlayer == iPlayer )
	{
		new Int:iNextLargest;
		for ( iNextLargest = iPlayer - 1; iNextLargest > 0; iNextLargest-- )
		{
			if ( PlayerGetInfo( iNextLargest, PINFO_CONNECT ) )
			{
				break;
			}
		}
		g_iLargestPlayer = iNextLargest;
	}

	pokemod_funcend_debug( "ForwardClientDisconnect" );
}

